const { Schema, model } = require('mongoose')

const schema = new Schema(
  {
    article: {
      type: Schema.Types.ObjectId,
      ref: 'Article'
    },
    user: {
      type: Schema.Types.ObjectId,
      ref: 'User'
    },
    content: String,
    createAt: {
      type: Date,
      default: Date.now()
    }
  },
  { versionKey: false }
)

const Comment = model('Comment', schema, 'Comment')

module.exports = { Comment }
